home *** CD-ROM | disk | FTP | other *** search
/ Power Programmierung / Power-Programmierung (Tewi)(1994).iso / magazine / progjour / 1991 / 01 / fontdemo.c < prev    next >
C/C++ Source or Header  |  1990-10-01  |  4KB  |  172 lines

  1. /**********************************************
  2.  
  3.    Program Name:   FONTDEMO.C
  4.    Author:         Ron Fosner
  5.    Creation Date:  March-90
  6.  
  7.    Copyright Ron Fosner, (c) 1990
  8.  
  9.    Description:
  10.      An program to demonstrate dynamic font generation.
  11.  
  12. ***********************************************/
  13.  
  14. /**********************************************/
  15.  
  16. #include   <stdio.h>
  17. #include   <stdlib.h>
  18. #include   <graph.h>
  19. #include "local.h"
  20.  
  21. /**********************************************/
  22.  
  23. /* dimensions of typical video screen */
  24.  
  25. #define X_RESOLUTION 10  /* 10 inches  */
  26. #define Y_RESOLUTION 7.5 /* 7.5 inches */
  27.  
  28. /* the video origin is in the upper left corner */
  29.  
  30. /**********************************************/
  31. /* function prototypes                        */
  32. /**********************************************/
  33.  
  34. void main( int argc, char **argv );
  35. void set_video( void );
  36.  
  37. /**********************************************/
  38. /* global data                                */
  39. /**********************************************/
  40.  
  41. int   PixelsperInch_x,PixelsperInch_y,Point_x,Point_y,Value_xy,Value_yx;
  42.  
  43. short color0 = 1, color1 = 1, color2 = 1;
  44.  
  45. POINT points_per_pixel;
  46.  
  47.  
  48. /**********************************************/
  49. /*
  50.    main: called with one argument that is the
  51.    location of the Bitstream Speedo font file
  52.    name. It then loops though a collection of
  53.    settings for the font, displaying a few
  54.    lines of text each time, while waiting for
  55.    a key press before proceeding.
  56. */
  57.  
  58. void main( int argc, char **argv )
  59. {
  60.      char * mssg;
  61.      int i;
  62.  
  63.      /* the following are the parameters for the
  64.       font calls */
  65.  
  66.      static int size = 6;
  67.      static int params[][6] =
  68.       {
  69.        { 24, 24,  0,  0},
  70.        { 72, 48,  0,  0},
  71.        { 72, 72,  0,  0},
  72.        { 72, 72, 12,  0},
  73.        { 72, 72,  0, 12},
  74.        { 72, 72, 12, 12},
  75.       };
  76.  
  77.      if ( argc != 2 )
  78.       {
  79.       printf("Need to specify a font file\n");
  80.       exit( 1 );
  81.       }
  82.  
  83.      /* reset the text drawing information */
  84.      /* need to get video information */
  85.      set_video();
  86.  
  87.      for ( i = 0 ; i < size ; i++ )
  88.       {
  89.  
  90.       /* erase entire screen */
  91.       ERASE_SCREEN;
  92.  
  93.       /* set the Speedo parameters to new values */
  94.  
  95.       Point_x  = params[i][0];
  96.       Point_y  = params[i][1];
  97.       Value_xy = params[i][2];
  98.       Value_yx = params[i][3];
  99.  
  100.       /* call Speedo to generate outlines */
  101.       if ( NULL != ( mssg = start_speedo( argv[1] ) ) )
  102.        {
  103.  
  104.        /* reset video mode */
  105.        /* print error message */
  106.         RESET_VIDEO_MODE;
  107.        printf("%s\n",mssg);
  108.        exit(1);
  109.        }
  110.  
  111.       origin();  /* clear screen, reset text origin */
  112.  
  113.       newline(); /* move down one line from the top */
  114.       place_text("Hello World!");
  115.  
  116.       newline();
  117.       place_text("Hi Again!\n"); /* note embedded newline */
  118.  
  119.       place_text("ABCDEabcde1234567890!");
  120.  
  121.       /* wait for a keypress */
  122.       WAIT_FOR_KEY;
  123.  
  124.       }
  125.  
  126.      /* reset video mode */
  127.      RESET_VIDEO_MODE;
  128.  
  129.  
  130. }
  131.  
  132.  
  133. /**********************************************/
  134. /*
  135.     set_video: this routine sets the video mode
  136.     to the graphics mode, generates the global
  137.     values for the video resolution, sets the
  138.     color values, then returns.
  139. */
  140.  
  141. void set_video( void )
  142. {
  143.      struct videoconfig config;
  144.  
  145.   if ( 0 == _setvideomode( VIDEO_MODE ) )
  146.       {
  147.       printf("Videomode failed\n");
  148.       exit(1);
  149.       }
  150.  
  151.      _getvideoconfig( &config );
  152.  
  153.      /* set the globa data */
  154.      video.x_pixels = config.numxpixels;
  155.      video.y_pixels = config.numypixels;
  156.      video.colors   = config.numcolors;
  157.  
  158.      if ( video.colors > 2 ) /* a color screen */
  159.       {
  160.       color0 = 15;/*_BRIGHTWHITE;*/
  161.       color1 = 1;/*_BLUE;*/
  162.       color2 = 1+8;/*_LIGHTBLUE;*/
  163.       }
  164.  
  165.      points_per_pixel.x = 72 * X_RESOLUTION / video.x_pixels;
  166.      points_per_pixel.y = 72 * Y_RESOLUTION / video.y_pixels;
  167.  
  168.      PixelsperInch_x = video.x_pixels / X_RESOLUTION;
  169.      PixelsperInch_y = video.y_pixels / Y_RESOLUTION;
  170.  
  171. }
  172.